package pl.edu.agh.io.fx3.saver.generators;

import java.io.IOException;
import java.sql.SQLException;

import pl.edu.agh.io.fx3.exceptions.ConfigFileException;
import pl.edu.agh.io.fx3.treecreator.disk.DiskConfigFileParser;
import pl.edu.agh.io.fx3.utils.JDBCInfo;

public class Generator {

	public static void main(String[] args) throws ConfigFileException, SQLException, IOException {
		if (args.length < 1) {
			System.err.println("Usage " + Generator.class.getCanonicalName() + " postgres|sqlite");
			System.exit(-1);
		}
		
		JDBCInfo jdbcInfo = DiskConfigFileParser.getJDBCInfo(Generator.class.getResourceAsStream( "/config.properties" ));
		
		if (args[0].equals("postgres")) {
			new PostgreSQLSchemaGenerator().generate(jdbcInfo);
		} else if (args[0].equals("sqlite")) {
			new SQLiteSchemaGenerator().generate(jdbcInfo);
		} else {
			System.err.println("Usage " + Generator.class.getCanonicalName() + " postgres|sqlite");
			System.exit(-1);
		}
	}

}
